//
//  WoDeEnterYanZhengMAView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/27.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "WoDeEnterYanZhengMAView.h"


@implementation WoDeEnterYanZhengMAView

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.enterTF];
    [_enterTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@0).offset(-100);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    [self addSubview:self.huoQuYanZhengMaButton];
    [_huoQuYanZhengMaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@0).offset(-15);
        make.width.equalTo(@80);
        make.centerY.equalTo(self.mas_centerY);
        make.height.equalTo(@25);
    }];
}
- (void)initOption{
    
}
- (UITextField *)enterTF{
    if (!_enterTF) {
        UITextField *tf = [[UITextField alloc]init];
        tf.backgroundColor = [UIColor whiteColor];
        tf.text = @"验证码";
        tf.textColor = TITLECOLOR;
        tf.delegate = self;
        tf.font = [UIFont systemFontOfSize:14];
        _enterTF = tf;
    }
    return _enterTF;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
    
}
- (void)drawRect:(CGRect)rect{
    
}
- (JKCountDownButton *)huoQuYanZhengMaButton{
    if (!_huoQuYanZhengMaButton) {
        JKCountDownButton *button = [JKCountDownButton buttonWithType:UIButtonTypeCustom];
        [button setTitleColor:SELECTEDCOLOR forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:12];
        button.layer.cornerRadius = 10;
        button.layer.masksToBounds  =YES;
        button.layer.borderColor = SELECTEDCOLOR.CGColor;
        button.layer.borderWidth = 1;
        [button setTitle:@"发送验证码" forState:UIControlStateNormal];
        [button addTarget:self action:@selector(passMoreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _huoQuYanZhengMaButton = button;
    }
    return _huoQuYanZhengMaButton;
}
- (void)passMoreButtonClick:(JKCountDownButton *)sender{
    if ([sender.titleLabel.text intValue] == 0) {
        [sender startCountDownWithSecond:59];
    }
    self.block();
//    [self sendYanZhengMaRequest];
}

@end
